package com.qiche.service.impl;

import java.util.List;

import com.qiche.model.LuckyDraw;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.qiche.mapper.LuckyDrawLogMapper;
import com.qiche.model.LuckyDrawLog;
import com.qiche.service.LuckyDrawLogService;

import tk.mybatis.mapper.entity.Example;


/**
 * Created by Linzw on 2018/01/24.
 */
@Service("luckyDrawLogService")
public class LuckyDrawLogServiceImpl extends BaseService<LuckyDrawLog> implements LuckyDrawLogService {
	
	@Autowired
	public LuckyDrawLogMapper luckyDrawLogMapper;
	
	public List<LuckyDrawLog> queryLuckyDrawLog(LuckyDraw luckyDraw,Long merchantId, Integer storeMemberId)throws Exception{
		Example example = new Example(LuckyDrawLog.class);
        Example.Criteria criteria = example.createCriteria();
        criteria.andEqualTo("merchantId",merchantId);
        criteria.andEqualTo("storeMemberId",storeMemberId);
        criteria.andGreaterThan("createTime",luckyDraw.getStartTime());
        criteria.andLessThan("createTime",luckyDraw.getEndTime());
        return luckyDrawLogMapper.selectByExample(example);
	}

	public List<LuckyDrawLog> selectByLuckyDrawId(Integer LuckyDrawId)throws Exception{
		Example example = new Example(LuckyDrawLog.class);
        Example.Criteria criteria = example.createCriteria();
        criteria.andEqualTo("luckyDrawId",LuckyDrawId);
        return luckyDrawLogMapper.selectByExample(example);
	}
}
